using Data.MapObject;
using MoonFramework.Scripts.Event;
using MoonFramework.Template;
using Tool;
using Tool.Name;

namespace Science
{
    /// <summary>
    /// 科技管理器
    /// </summary>
    public class ScienceManager : BaseManager<ScienceManager>
    {
        private ScienceData _scienceData;
        
        public void Init()
        {
            _scienceData = ArchiveManager.Instance.ScienceData;
            EventCenter.Instance.SendCommand(EventName.SaveGame, OnDestroy);
        }
        
        /// <summary>
        /// 检测解锁
        /// </summary>
        public bool CheckUnlockScience(int ID)
        {
            return _scienceData.CheckUnlockScience(ID);
        }

        /// <summary>
        /// 添加科技
        /// </summary>
        public void AddScience(int ID)
        {
            _scienceData.AddScience(ID);
        }

        private void OnDestroy()
        {
            ArchiveManager.Instance.SaveScienceData(0);
        }
    }
}